package com.rmy.publish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rmy.common.annotation.Log;
import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.AjaxResult;
import com.rmy.common.enums.BusinessType;
import com.rmy.publish.domain.MipsControllerInfo;
import com.rmy.publish.service.IMipsControllerInfoService;
import com.rmy.common.utils.poi.ExcelUtil;
import com.rmy.common.core.page.TableDataInfo;

/**
 * 控件信息Controller
 * 
 * @author rmy
 * @date 2023-05-26
 */
@RestController
@RequestMapping("/publish/mipsControllerInfo")
public class MipsControllerInfoController extends BaseController
{
    @Autowired
    private IMipsControllerInfoService mipsControllerInfoService;

    /**
     * 查询控件信息列表
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MipsControllerInfo mipsControllerInfo)
    {
        startPage();
        List<MipsControllerInfo> list = mipsControllerInfoService.selectMipsControllerInfoList(mipsControllerInfo);
        return getDataTable(list);
    }

    /**
     * 导出控件信息列表
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:export')")
    @Log(title = "控件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MipsControllerInfo mipsControllerInfo)
    {
        List<MipsControllerInfo> list = mipsControllerInfoService.selectMipsControllerInfoList(mipsControllerInfo);
        ExcelUtil<MipsControllerInfo> util = new ExcelUtil<MipsControllerInfo>(MipsControllerInfo.class);
        util.exportExcel(response, list, "控件信息数据");
    }

    /**
     * 获取控件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:query')")
    @GetMapping(value = "/{controllerId}")
    public AjaxResult getInfo(@PathVariable("controllerId") Long controllerId)
    {
        return AjaxResult.success(mipsControllerInfoService.selectMipsControllerInfoByControllerId(controllerId));
    }

    /**
     * 新增控件信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:add')")
    @Log(title = "控件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MipsControllerInfo mipsControllerInfo)
    {
        return toAjax(mipsControllerInfoService.insertMipsControllerInfo(mipsControllerInfo));
    }

    /**
     * 修改控件信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:edit')")
    @Log(title = "控件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MipsControllerInfo mipsControllerInfo)
    {
        return toAjax(mipsControllerInfoService.updateMipsControllerInfo(mipsControllerInfo));
    }

    /**
     * 删除控件信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsControllerInfo:remove')")
    @Log(title = "控件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{controllerIds}")
    public AjaxResult remove(@PathVariable Long[] controllerIds)
    {
        return toAjax(mipsControllerInfoService.deleteMipsControllerInfoByControllerIds(controllerIds));
    }
}
